module cl {
	export class ScoutAction extends ActionPerformer {
		constructor() {
			super();
			this.type = 3;
			this.paramKeys = JSON.stringify([]);
			this.paramVals = JSON.stringify([]);
		}

		public accept() : void {
			// 看见目标区域
			ActionUtil.setAction(new SeeAction(Campaign.troop_force[this.troopid]), this.troopid, this.move_remain, this.tid).accept();

			// 数据
			Campaign.troop[this.troopid].move_remain = this.move_remain;
		}

		public acceptOnce() : void { this.accept(); }

		public duration() : number {
			return 3000;
		}

		public play(map : CampaignPage) : void {
            let troop = Campaign.troop[this.troopid];

            let troopGroup = map.groupCourtTroop.getChildByName(String(this.troopid)) as eui.Group;
            map.groupCourtTroop.removeChild(troopGroup);

            let coord0 = Map.tileEngine.tile2coord(troop.force_tile);
            let coord1 = Map.tileEngine.tid2coord(this.tid);

			// 看见目标区域
            ActionUtil.setAction(new SeeAction(troop.force), this.troopid, this.move_remain, this.tid).play(map);

            // 动作动画
            let flyEffect = new FlyEffect(map, troopGroup, coord0, coord1,
                    () : void => {},
                    () : void => {
                        map.troopManager.setCourtTroopLocation(troop, troopGroup);
                        Util.setOrientation(troopGroup.getChildAt(1), troop.orientation);
                        map.groupCourtTroop.addChild(troopGroup);
						MoveRemainEffect.play(troopGroup, this.move_remain);
                    });
            flyEffect.start();
        }
	}
}